﻿using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;

using Microsoft.Xna.Framework;

using System;
using System.Collections.Generic;
using System.Threading;




namespace FXnaEngine
{

    /// <summary>
    /// 用于封装一定的底层逻辑
    /// </summary>
    public class BaseGame
    {


        public BaseGame()
        {


            this.gameTime = new GameTime();




        }


        #region 一些公共静态变量

   






        #endregion



        #region 私有字段

        //服务提供

        //ServiceContainer services;




        //GraphicsDevice _graphicsDevice;



        //IGraphicsDeviceService _graphicsDeviceService;

     




        //ContentManager _content;



        /// <summary>
        /// Render delegate for rendering methods, also used for many other
        /// methods.
        /// </summary>
        public delegate void RenderHandler();



        private GameTime gameTime;




        bool initialized;



    
        #endregion




        #region props



        public GameServiceContainer Services
        {
            get { return FEngineState.Services; }

        }




        public IGraphicsDeviceService GraphicsDeviceService
        {
            get { return FEngineState.GraphicsDeviceService; }
           
        }


        public ContentManager Content
        {
            get { return FEngineState.Content; }

        }

        public GraphicsDevice GraphicsDevice
        {
            get { return FEngineState.Device; }

        }



        public GameTime GameTime
        {
            get { return gameTime; }

            set { this.gameTime = value; }
        }





        bool _isMouseVisible=true;

        public bool IsMouseVisible
        {
            get { return _isMouseVisible; }
            set { _isMouseVisible = value; }
        }


        //为控件专门准备的参数

        public System.Drawing.Point Location
        {
            get;
            set;
        }

       //public System.Drawing.Size Size
       //{
       //    get;
       //    set;
       //}


        #endregion


        #region method


        #region 私有方法

       


        #endregion



        /// <summary>
        /// 基类需要重写，但是必须在基础方法之后调用
        /// </summary>
        /// <param name="graphics"></param>
        /// <param name="content"></param>
        /// <param name="services"></param>
       public virtual void InitEngine(IGraphicsDeviceService graphics, ContentManager content, GameServiceContainer services)
        {

            if (graphics == null || content == null)
                throw new Exception("graphics or content can not be null");

            


           //将一些特定的操作留给底层


            FEngineState.InitEngine(graphics,content,services);

          

            initialized = true;





         

        }


        #endregion

    }
}
